<!--********************************************************************
* Copyright© 2000 - 2025 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title data-i18n="resources.title_3baidu"></title>
    <style type="text/css">
        .editPane {
            position: absolute;
            top: 50px;
            right: 50px;
            text-align: center;
            background: #FFF;
            z-index: 1000;
        }

    </style>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
    <div class='panel-heading'>
        <h5 class='panel-title text-center' data-i18n="resources.text_baidu"></h5>
    </div>
    <div class='panel-body' id='params'>
        <p></p>
        <div align='right' class='button-group'>
            <input type='button' id='btn1' class='btn btn-primary' data-i18n="[value]resources.text_input_value_addData"
                   onclick="addData()"/>
            <input type='button' id='btn2' class='btn btn-primary'
                   data-i18n="[value]resources.text_input_value_removeData" onclick="removeData()"/>
        </div>
    </div>
</div>
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" include="baidu" src="../../dist/classic/include-classic.js"></script>
<script type="text/javascript">
    var map, baiduLayer, vector, dataAdded = false;
    map = new SuperMap.Map("map", {
        controls: [
            new SuperMap.Control.Navigation(),
            new SuperMap.Control.Zoom(),
            new SuperMap.Control.MousePosition()
        ]
    });
    baiduLayer = new SuperMap.Layer.Baidu();
    vector = new SuperMap.Layer.Vector("vector");
    map.addLayers([baiduLayer, vector]);
    addData();
    map.setCenter(new SuperMap.LonLat(0, 0), 0);

    function addData() {
        if (!dataAdded) {
            vector.removeAllFeatures();
            //点对象
            var point = new SuperMap.Geometry.Point(0, 0);
            var pointVector = new SuperMap.Feature.Vector(point);
            pointVector.style = {
                fillColor: "red",
                strokeColor: "yellow",
                pointRadius: 10
            };

            // 矩形
            var x = 7577600;
            var y = 1900544;
            var w = 8000000;
            var h = 6000000;
            var rectangle = new SuperMap.Geometry.Rectangle(x, y, w, h);
            var rectangleVector = new SuperMap.Feature.Vector(rectangle);
            rectangleVector.style = {
                fillOpacity: 0.02,
                strokeOpacity: 0.1
            };

            vector.addFeatures([pointVector, rectangleVector]);
            dataAdded = true;
        } else {
            widgets.alert.showAlert(resources.msg_loadedData, true, 200);
        }
    }

    function removeData() {
        dataAdded = false;
        vector.removeAllFeatures();
        vector.refresh();
        widgets.alert.clearAlert();
    }
</script>
</body>
</html>